package com.officegameapp.service;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.officegameapp.db.dao.DAOFactory;
import com.officegameapp.db.dao.IGameTableDAO;
import com.officegameapp.db.entities.GameTable;

@Path("/tables")
public class GameTableService {

	private IGameTableDAO gameTableDAO;
	
	public GameTableService() {
		gameTableDAO = DAOFactory.getDAOFactory(DAOFactory.MYSQL_DAO).getGameTableDAO();
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<GameTable> getGameTables() {
		List<GameTable> tables = gameTableDAO.getGameTables();
		return tables;
	}
	
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_JSON)
	public GameTable createGameTable(GameTable message) {
		gameTableDAO.persist(message);
		return message;
	}
	
}
